package com.tudouji.project.mt.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.mt.domain.MtWhout;
import com.tudouji.project.mt.service.IMtWhoutService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 美团出库单主Controller
 * 
 * @author tudouji
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/mt/whout")
public class MtWhoutController extends BaseController
{
    @Autowired
    private IMtWhoutService mtWhoutService;

    /**
     * 查询美团出库单主列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MtWhout mtWhout)
    {
        startPage();
        List<MtWhout> list = mtWhoutService.selectMtWhoutListPC(mtWhout);
        return getDataTable(list);
    }

    /**
     * 导出美团出库单主列表
     */
    @PreAuthorize("@ss.hasPermi('mt:whout:export')")
    @Log(title = "美团出库单主", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MtWhout mtWhout)
    {
        List<MtWhout> list = mtWhoutService.selectMtWhoutList(mtWhout);
        ExcelUtil<MtWhout> util = new ExcelUtil<MtWhout>(MtWhout.class);
        return util.exportExcel(list, "whout");
    }

    /**
     * 获取美团出库单主详细信息
     */
    @PreAuthorize("@ss.hasPermi('mt:whout:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mtWhoutService.selectMtWhoutById(id));
    }

    /**
     * 新增美团出库单主
     */
    @PreAuthorize("@ss.hasPermi('mt:whout:add')")
    @Log(title = "美团出库单主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MtWhout mtWhout)
    {
        return toAjax(mtWhoutService.insertMtWhout(mtWhout));
    }

    /**
     * 修改美团出库单主
     */
    @PreAuthorize("@ss.hasPermi('mt:whout:edit')")
    @Log(title = "美团出库单主", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MtWhout mtWhout)
    {
        return toAjax(mtWhoutService.updateMtWhout(mtWhout));
    }

    /**
     * 删除美团出库单主
     */
    @PreAuthorize("@ss.hasPermi('mt:whout:remove')")
    @Log(title = "美团出库单主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mtWhoutService.deleteMtWhoutByIds(ids));
    }
}
